<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
[#include "/admin/include/head.htm"]
<script type="text/javascript">
	var grid;
	$(function(){
		 grid = $("#maingrid").ligerGrid({
            columns: [
			{name: 'id', hide: true, width:0, isAllowHide: false},
			{display: '名称', name: 'name', align: 'left', width: 200 },
			{display: '备注', name: 'memo', align: 'left', width: 300 },
			{display: '是否默认', name: 'isDefault', align: 'center', dict: 'common',width: 120,
				render:function(row){
					return "<a href='javascript:void(0)' onclick='switchDefault("+row['id']+")'>"+row['isDefault']+"</a>";
				}
			}],  pageSize:20, url: 'queryData.jhtml', width: '100%', height:'100%', enabledSort: true,toolbar:{}
        });
        $("#pageloading").hide();
		LG.loadToolbar(grid);
		
		//绑定搜索按钮
		LG.search(grid);
	});
	
	function add(){
		top.f_addTab(null, '新增快递单模版', base + '/admin/b2c/deliveryTemplate/add.jhtml');
	}
	
	function edit(){
		var selecteds = grid.getSelecteds();
		if(selecteds && selecteds.length == 1){
			var id = selecteds[0].id;
			if(top.f_isTabItemExist("deliveryTemplate" + id)){
				top.f_switchTab("deliveryTemplate" + id);
			}else{
				top.f_addTab("deliveryTemplate" + id, '修改快递单模版[' + selecteds[0].name+ ']', '${base}/admin/b2c/deliveryTemplate/edit.jhtml?id=' + id);
			}
		}else{
			LG.tip('请选择一行!');
		}
	}
	
	function f_delete() {
		var selecteds = grid.getSelecteds();
	    if (selecteds.length > 0) {
	    	jQuery.ligerDialog.confirm('确定删除吗？', function (confirm) {
      			if (confirm){
					LG.ajax({
						url: base + '/admin/b2c/deliveryTemplate/delete.jhtml',
			            loading: '正在删除中...',
			            data: { ids: LG.getIds(selecteds).join(',') },
			            success: function () {
							LG.showSuccess('删除成功');
			                f_reload();
			            },
			            error: function (message) {
							LG.showError(message);
			            }
			        });
			    }
			});
		} else {
			LG.tip('请选择行!');
	    }
	}
	
	function switchDefault(id){
		LG.ajax({
			url: base + '/admin/b2c/deliveryTemplate/default.jhtml',
	        data: { id: id },
	        success: function (data) {
	        	LG.showSuccess(data.content);
	        	f_reload('maingrid');
	        },
	        error: function (message) {
				LG.showError(message);
	        }
	     });
	}
</script>
</head>
<body style="padding:10px; overflow:hidden;">
	<div id="functions">
		<div class="clearfix">
			<div style="float:left;">	
				<span>
					名称：<input style="width: 150px" name="search_LIKE_name" type="text" class="formText">
				</span>
				<input type="button" id="search" class="button" value="搜索"/>
				<a href="#" id="search_btn_reset" face="Wingdings 3">清除本次搜索</a>
			</div>
		</div>
	</div>
	<div id="maingrid" style="margin:0; padding:0"></div>
</body>
</html>